/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_LITE_TOOL_DELAY_SSAP_CLIENT_H
#define SLE_LITE_TOOL_DELAY_SSAP_CLIENT_H

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#include "kh_sle_ssap_client.h"
#include "kh_sle_connect.h"
#include "cmd_input.h"
#include "sle_hilog.h"

#include <stdio.h>
#include <string.h>
#include <stdint.h>

#ifdef __LITEOS_M__
#include "common_tool.h"
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "utils_file.h"
#endif // __LITEOS_M__

//client callback
void OnSleTNotificatedDelayCb(uint8_t clientId, uint16_t connectId
        , const ClientHandleValue *data, SleErrorCode errCode);
static SleSsapcCallbacks g_ssapcToolDelayCbs = {
        .OnSleNotificatedCb = OnSleTNotificatedDelayCb,
};

//connect callback
void OnSleTConnStateChangeDelayCb(uint16_t connectId, const SleDeviceAddress *addr
        , SleConnectState connState, SlePairState pairState, SleDisConnectReason discReason);
static SleConnectCallbacks g_connectToolDelayCbs = {
        .OnSleConnStateChangeCb = OnSleTConnStateChangeDelayCb,
};

//helper
void SleSsapClientToolHalperDelay(void);
//client func
void TAddSspaClientDelay(void);
void TSendExchangeInfoReqDelay(void);
void TStartIperfFromAllServerDelay(void);
void TStartIperfClientToServerDelay(void);
void TimeCountDelay(void);
void TIperf_RTT(void);
void TResetStartIperfFromAllServer(void);
//connect func
void TSleUpdateConnParamToAllDelay(void);
void TSleConnectDelay(void);
void TSleDisConnectDelay(void);
//void TConnectTestTenDevice(void);
void *abnormalRetryConnect(void *addr);
void TGetHasConnectDevice(void);
void TConnectAllDevice(void);

static CmdNode g_ssapClientDelayCmdList[] = {
        //sle_ssap_client_test
        {"SleSsapClientHalperDelay", SleSsapClientToolHalperDelay},
        {"AddSsapClientDelay", TAddSspaClientDelay},
        {"SleConnectDelay", TSleConnectDelay},
        {"SleUpdateConnParamToAllDelay", TSleUpdateConnParamToAllDelay},
        {"SendExchangeInfoReqDelay", TSendExchangeInfoReqDelay},
        {"StartIperfFromAllServerDelay", TStartIperfFromAllServerDelay},
        {"StartIperfClientToServerDelay", TStartIperfClientToServerDelay},
        {"TimeCountDelay", TimeCountDelay},
        {"SleDisConnectDelay", TSleDisConnectDelay},
        {"GetHasConnectDevice", TGetHasConnectDevice},
        {"ConnectAllDevice", TConnectAllDevice},
        {"TIperf_RTT", TIperf_RTT},
        {"ResetStartIperfFromAllServer", TResetStartIperfFromAllServer},
};

//uitl func
uint64_t sle_khtest_clock_gettime_us(void);
void *TIperfClientToServerThread(void *arg);

static uint16_t g_ssapClientDelayCmdNum = sizeof(g_ssapClientDelayCmdList) / sizeof(CmdNode);
void SleSsapClientToolCmdHandlerDelay(int argc, char **argv);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif //SLE_LITE_TOOL_DELAY_SSAP_CLIENT_H